home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / extras / falcon / dsptrack / tracker.s < prev    next >
Text File  |  1995-04-27  |  40KB  |  1,581 lines

  1. ***********************************************************************
  2. ***********                                        ***********
  3. ***********                                        ***********
  4. ***********           DSP SoundTracker Replay            ***********
  5. ***********                                        ***********
  6. ***********       Runs with most 4/6/8 Voices .MOD        ***********
  7. ***********                                        ***********
  8. ***********            by Simplet / ABSTRACT            ***********
  9. ***********                                        ***********
  10. ***********                                        ***********
  11. ***********************************************************************
  12.  
  13.                 RsReset
  14.  
  15. Amiga_Name        rs.b        22
  16. Amiga_Length        rs.w        1    * Taille codée en words
  17. Amiga_Fine_Tune    rs.b        1    * de 0 à 15  =  0 à 7 et -8 à -1
  18. Amiga_Volume        rs.b        1    * de 0 à 64
  19. Amiga_Repeat_Start    rs.w        1
  20. Amiga_Repeat_Length    rs.w        1
  21.  
  22. Amiga_Size        rs.b        1    * 30 octets
  23.  
  24.  
  25.                 RsReset
  26.  
  27. Voice_Sample_Start            rs.l        1
  28. Voice_Sample_Offset            rs.l        1
  29. Voice_Sample_Position        rs.l        1
  30. Voice_Sample_Length            rs.l        1
  31. Voice_Sample_Repeat_Length    rs.l        1
  32. Voice_Sample_Volume            rs.w        1
  33. Voice_Sample_Period            rs.w        1
  34. Voice_Sample_Fine_Tune        rs.w        1
  35.  
  36. Voice_Start                rs.l        1
  37. Voice_Length                rs.l        1
  38. Voice_Repeat_Length            rs.l        1
  39. Voice_Volume                rs.w        1
  40. Voice_Period                rs.w        1
  41. Voice_Wanted_Period            rs.w        1
  42.  
  43. Voice_Note                rs.w        1
  44. Voice_Sample                rs.b        1
  45. Voice_Command                rs.b        1
  46. Voice_Parameters            rs.b        1
  47.  
  48. Voice_Tone_Port_Direction    rs.b        1
  49. Voice_Tone_Port_Speed        rs.b        1
  50. Voice_Glissando_Control        rs.b        1
  51. Voice_Vibrato_Command        rs.b        1
  52. Voice_Vibrato_Position        rs.b        1
  53. Voice_Vibrato_Control        rs.b        1
  54. Voice_Tremolo_Command        rs.b        1
  55. Voice_Tremolo_Position        rs.b        1
  56. Voice_Tremolo_Control        rs.b        1
  57. Voice_Funk_Speed            rs.b        1
  58. Voice_Funk_Offset            rs.b        1
  59. Voice_Funk_Position            rs.l        1
  60. Voice_Funk_Start            rs.l        1
  61.  
  62. Voice_Size                rs.b        1
  63.  
  64. ***********************************************************************
  65. ***********                Initialisations            ***********
  66. ***********************************************************************
  67.  
  68.         Section    TEXT
  69.  
  70. Init_Music
  71.         bsr        Init_Module
  72.         bra        Init_Sound
  73.  
  74. Init_Music_IT
  75.         clr.b    $fffffa19.w            ; Coupe Timer
  76.         move.l    #SndTrack_Timer,$134.w    ; Installe Vecteur
  77.         bset.b    #5,$fffffa07.w            ; Autorise Timer
  78.         bset.b    #5,$fffffa13.w            ; DéMaske Timer
  79.         move.b    Simplet_IT_Timer_Data(pc),$fffffa1f.w
  80.         move.b    Simplet_IT_Timer_Control(pc),$fffffa19.w
  81.         rts
  82.  
  83. Stop_Music_IT
  84.         clr.b    $fffffa19.w            ; Coupe Timer
  85.         bclr.b    #5,$fffffa07.w            ; Autorise Timer
  86.         bclr.b    #5,$fffffa13.w            ; DéMaske Timer
  87.         rts
  88.  
  89. Stop_Music
  90.         move.b    #$80+$28/2,$ffffa201.w    ; Host User 1, vecteur $28
  91.         rts
  92.  
  93. ***********************************************************************
  94. ***********       Interruptions du Replay Soundtracker        ***********
  95. ***********************************************************************
  96.  
  97. SndTrack_Timer
  98.         bclr.b    #5,$fffffa0f.w        ; à Cause du mode SEI
  99.         move.w    #$2300,sr            ; Ne bloque pas tout le monde
  100.  
  101.         ror.w    SndTrack_Timer_Cmpt
  102.         bcc.s    SndTrack_Timer_Ret
  103.  
  104.         move.b    Simplet_IT_Timer_Data(pc),$fffffa1f.w
  105.         move.b    Simplet_IT_Timer_Control(pc),$fffffa19.w
  106.         move.w    Simplet_IT_Sample_Length(pc),Code_Sample_Length
  107.         bsr.s    SndTrack_IT
  108.  
  109. SndTrack_Timer_Ret
  110.         rte
  111.  
  112. SndTrack_Timer_Cmpt
  113.         dc.w        %0001000100010001
  114.  
  115.  
  116. SndTrack_IT
  117.         move.l    $ffff9800.w,-(sp)
  118.         move.l    #$ff000000,$ffff9800.w
  119.  
  120.         movem.l    d0-d7/a0-a6,-(sp)
  121.  
  122. ; Signale au DSP qu'on veut causer à la routine Soundtracker
  123.         move.b    #$80+$26/2,$ffffa201.w    ; Host User 0, vecteur $26
  124.  
  125. ; Port Host
  126.         lea.l    $ffffa204.w,a6
  127.  
  128. ; On balance le nombre de samples à calculer (code automodifié)
  129. SplLen    move.l    #984,(a6)
  130.  
  131. Code_Sample_Length    equ    SplLen+4
  132.  
  133.  
  134.         moveq.l    #0,d7
  135.         move.w    Simplet_Voices_Nb(pc),d7
  136.         subq.w    #2,d7
  137.         lsr.w    d7
  138.         move.l    d7,(a6)    ; Nombre de paires de voies supplémentaires
  139.  
  140. ; Envoie les samples au DSP
  141.  
  142.         lea.l    Simplet_Voices(pc),a5        ; Gauche
  143.         bsr.s    Play_Voice
  144.         lea.l    Voice_Size(a5),a5            ; Droite
  145.         bsr.s    Play_Voice
  146.  
  147.         subq.w    #1,d7
  148.  
  149. Play_All_Voices
  150.         adda.w    Increment_Voice_1(pc),a5
  151.         bsr.s    Play_Voice
  152.         adda.w    Increment_Voice_2(pc),a5
  153.         bsr.s    Play_Voice
  154.  
  155.         subq.w    #1,d7
  156.         bmi.s    No_More_Voices
  157.  
  158.         adda.w    Increment_Voice_3(pc),a5
  159.         bsr.s    Play_Voice
  160.         adda.w    Increment_Voice_4(pc),a5
  161.         bsr.s    Play_Voice
  162.  
  163.         subq.w    #1,d7
  164.         bpl.s    Play_All_Voices
  165.  
  166.  
  167. ; S'occupe de la partition
  168.  
  169. No_More_Voices
  170.         bsr        Simplet_Play_Patterns
  171.  
  172.         movem.l    (sp)+,d0-d7/a0-a6
  173.  
  174.         move.l    (sp)+,$ffff9800.w
  175.         rts
  176.  
  177. ; S'occupe d'une voie : envoie volume, fréquence et les samples
  178.  
  179. Play_Voice
  180. ; Envoie volume
  181.         moveq.l    #0,d0
  182.         move.w    Voice_Sample_Volume(a5),d0
  183.         mulu.l    #$7fffff/64*2,d0
  184.         moveq.l    #0,d1
  185.         move.w    Simplet_Voices_Nb(pc),d1
  186.         divu.l    d1,d0
  187.         move.l    d0,(a6)
  188.  
  189. ; Envoie fréquence relative
  190.         move.l    #$800000/49169*428*8363,d0
  191.         moveq.l    #0,d1
  192.         move.w    Voice_Sample_Period(a5),d1
  193.         divu.l    d1,d0
  194.         move.l    d0,(a6)
  195.  
  196. ; Explication du calcul :
  197. ; Fréquence de replay d'une note =
  198. ; Periode de la Note * Base du DO-2 / Periode du DO-2
  199. ; Nous on veut le rapport avec la fréquence de Replay donc / 49169
  200. ; et résultat à virgule prémultiplié par $800000 pour le DSP
  201.  
  202. ; Recoie longueur du sample à envoyer
  203. WaitDSP    btst.b    #0,$ffffa202.w
  204.         beq.s    WaitDSP
  205.         move.l    (a6),d0
  206.  
  207.         movea.l    Voice_Sample_Start(a5),a0
  208.         move.l    Voice_Sample_Position(a5),d2
  209.         adda.l    d2,a0                ; Adresse courante
  210.         add.l    d0,d2                ; Nouvelle position d'arrivée
  211.  
  212.         cmp.l    Voice_Sample_Length(a5),d2    ; A-t'on dépassé la fin ?
  213.         blt.s    No_Repeat                    ; Si Non pas de probleme
  214.  
  215.         sub.l    Voice_Sample_Repeat_Length(a5),d2    ; Si Oui, boucle
  216.  
  217. No_Repeat    move.l    d2,Voice_Sample_Position(a5)    ; Nouvelle position
  218.  
  219.         ext.l    d0
  220.         divu.l    #6,d0                ; Envoi par paquet de 6 un
  221.         addq.w    #1,d0                ; de + car on tombe pas pile
  222.         move.l    d0,(a6)                ; Nombre de paquets
  223.  
  224.         subq.w    #1,d0                ; pour le dbra
  225.         subq.l    #1,a0                ; Cale les samples
  226.  
  227. Send_Samples
  228.         move.l    (a0),(a6)
  229.         move.l    3(a0),(a6)
  230.         addq.l    #6,a0
  231.         dbra        d0,Send_Samples
  232.         rts
  233.  
  234. ***********************************************************************
  235. ***********           Initialisations Son et DSP            ***********
  236. ***********************************************************************
  237.  
  238. Init_Sound
  239. * Stoppe la lecture DMA au cas où...
  240.         clr.b    $ffff8901.w
  241.  
  242. * DAC sur piste 0 (quartet fort)
  243.         move.b    #$0f,$ffff8920.w
  244.  
  245. * Source DSP-Xmit sur Horloge Interne 25.175 MHz, DSP connecté (Enable)
  246. * Source DMA-Play sur Horloge Interne 25.175 MHz
  247.         move.w    #%10010001,$ffff8930.w
  248.  
  249. * Destinations DAC, DMA-Record et External OutPut
  250. * connectées à Source DSP-Xmit, Handshaking On
  251. * Destination DSP-Rec connectée sur DMA-Play, DSP connecté (Enable)
  252.         move.w    #%0010001000010011,$ffff8932.w
  253.  
  254. * Fréquence 49169 Hz
  255.         move.b    #1,$ffff8935.w
  256.  
  257. * Seulement Matrice et pas le PSG-Yamaha
  258.         move.b    #%10,$ffff8937.w
  259.  
  260. * Programme DSP
  261.         move.w    #113,-(sp)                ; DSP_RequestUniqueAbility
  262.         trap        #14                        ; XBios
  263.         addq.l    #2,sp
  264.  
  265.         move.w    d0,-(sp)                    ; No Ability
  266.         move.l    #(DSP_End-DSP_Code)/3,-(sp)    ; Longueur en Mots DSP
  267.         pea.l    DSP_Code(pc)                ; Adresse du code binaire
  268.         move.w    #109,-(sp)                ; Dsp_ExecProg
  269.         trap        #14                        ; XBios
  270.         lea.l    12(sp),sp
  271.  
  272.  
  273. Connect    move.l    #87654321,$ffffa204.w
  274.         moveq.l    #0,d0
  275.  
  276. Conct_Get    btst.b    #0,$ffffa202.w
  277.         bne.s    DSP_Test
  278.         addq.l    #1,d0
  279.         cmp.l    #100000,d0
  280.         beq.s    DSP_Error
  281.         bra.s    Conct_Get
  282.  
  283. DSP_Test    move.l    $ffffa204.w,d0
  284.         cmp.l    #12345678,d0
  285.         beq.s    DSP_Ok
  286.  
  287. DSP_Error    moveq.l    #-1,d0
  288. DSP_Ok    rts
  289.  
  290. ***********************************************************************
  291. ***********            Initialisations du Module        ***********
  292. ***********************************************************************
  293.  
  294. Init_Module
  295.         lea.l    Module,a0
  296.  
  297.         lea.l    20+31*30+2(a0),a1        ; Par défaut
  298.         lea.l    4+128(a1),a2            ; Type
  299.         moveq.l    #31,d0                ; 31 instruments
  300.         moveq.l    #64,d2                ; 64 lignes par pattern
  301.         sf        Simplet_Old_Module
  302.  
  303.         move.b    #125,Simplet_Tempo        ; Tempo par défaut
  304.         move.b    #6,Simplet_Speed        ; Vitesse par défaut
  305.         move.b    #5,Simplet_IT_Timer_Control
  306.         move.b    #192,Simplet_IT_Timer_Data
  307.         move.w    #984,Simplet_IT_Sample_Length
  308.  
  309.         move.l    $438(a0),d3            ; ModFile Chunk
  310.  
  311. ; Formats 4 voies
  312.         moveq.l    #4,d1
  313.  
  314.         cmp.l    #"M.K.",d3
  315.         beq.s    Format_Ok
  316.         cmp.l    #"M!K!",d3
  317.         beq.s    Format_Ok
  318.         cmp.l    #"M&K&",d3
  319.         beq.s    Format_Ok
  320.         cmp.l    #"FA04",d3
  321.         beq.s    Format_Digital
  322.         cmp.l    #"FLT4",d3
  323.         beq.s    Format_Ok
  324.  
  325. ; Formats 6 voies
  326.         moveq.l    #6,d1
  327.  
  328.         cmp.l    #"FA06",d3
  329.         beq.s    Format_Digital
  330.         cmp.l    #"6CHN",d3
  331.         beq.s    Format_Ok
  332.         cmp.l    #"FLT6",d3
  333.         beq.s    Format_Ok
  334.  
  335. ; Formats 8 voies
  336.         moveq.l    #8,d1
  337.  
  338.         cmp.l    #"FA08",d3
  339.         beq.s    Format_Digital
  340.         cmp.l    #"8CHN",d3
  341.         beq.s    Format_Ok
  342.         cmp.l    #"FLT8",d3
  343.         beq.s    Format_Ok
  344.         cmp.l    #"OCTA",d3
  345.         beq.s    Format_Ok
  346.  
  347. ; Si rien de spécial alors c'est un ancien module 15 instruments
  348.         lea.l    20+15*30+2(a0),a1
  349.         lea.l    128(a1),a2
  350.         moveq.l    #15,d0
  351.         moveq.l    #4,d1
  352.         st        Simplet_Old_Module
  353.         bra.s    Format_Ok
  354.  
  355. Format_Digital
  356.         move.w    (a2)+,d2
  357.         addq.l    #2,a2
  358.  
  359. Format_Ok    move.l    a1,Simplet_Sequence_Adr    ; Adresse de la séquence
  360.         move.l    a2,Simplet_Patterns_Adr    ; Adresse des patterns
  361.         move.w    d0,Simplet_Samples_Nb    ; Nombre d'instruments
  362.         move.w    d1,Simplet_Voices_Nb    ; Nombre de voies
  363.         move.w    d2,Simplet_Pattern_Length
  364.  
  365.         lsl.w    #2,d1
  366.         move.w    d1,Simplet_Line_Size    ; Taille d'une 'ligne'
  367.         mulu.w    d2,d1
  368.         move.w    d1,Simplet_Pattern_Size    ; Taille d'un pattern
  369.  
  370.         move.b    -2(a1),d0
  371.         move.w    d0,Simplet_Song_Length    ; Longueur du module
  372.         move.b    -1(a1),d2
  373.         cmp.b    d0,d2                ; le Restart
  374.         blo.s    Simplet_Restart_Ok        ; est-il cohérent ?
  375.         moveq.l    #0,d2                ; si non, Restart = 0
  376. Simplet_Restart_Ok
  377.         move.w    d2,Simplet_Song_Restart
  378.  
  379.         subq.w    #1,d0                ; Parcours la séquence
  380.         moveq.l    #0,d1                ; jusqu'à la dernière
  381. Simplet_Sequence_Loop                    ; position
  382.         move.b    (a1)+,d2                ; No Pattern
  383.         cmp.b    d1,d2                ; Plus grand
  384.         blo.s    Simplet_Seq_No_Max        ; que le maximum ?
  385.         move.b    d2,d1                ; alors Nouveau maximum
  386. Simplet_Seq_No_Max
  387.         dbra        d0,Simplet_Sequence_Loop
  388.  
  389.  
  390.         addq.w    #1,d1                    ; Nombre de patterns
  391.         mulu.w    Simplet_Pattern_Size(pc),d1    ; Taille totale
  392.  
  393.         move.l    Simplet_Patterns_Adr(pc),a1    ; Adresse du début
  394.         lea.l    (a1,d1.l),a1                ; Des samples
  395.  
  396.         lea.l    20(a0),a2                ; Pointe sur Sample 1
  397.         moveq.l    #0,d2
  398.         move.w    Simplet_Samples_Nb(pc),d0
  399.         subq.w    #1,d0
  400.  
  401. Simplet_Total_Length
  402.         move.w    Amiga_Length(a2),d3        ; Longueur
  403.         ext.l    d3                    ; du sample
  404.         add.l    d3,d3                ; * 2 car stocké en words
  405.         add.l    d3,d2                ; Ajoute au total
  406.         lea.l    Amiga_Size(a2),a2        ; Instrument suivant
  407.         dbra        d0,Simplet_Total_Length    ; Calcule longueur totale
  408.  
  409.  
  410. ; Recopie les samples à la fin de la zone de travail temporaire
  411. ; pour justement pouvoir travailler dessus, les préparer au bouclage
  412.         lea.l    WorkSpace,a2
  413.  
  414.         move.l    a1,a3
  415.         add.l    d2,a1
  416.  
  417. Simplet_Move_Samples
  418.         move.l    -(a1),-(a2)
  419.         move.l    -(a1),-(a2)
  420.         subq.l    #8,d2
  421.         bpl.s    Simplet_Move_Samples
  422.  
  423.  
  424. ; Maintenant, on bosse sur les samples
  425.         lea.l    20(a0),a0                    ; Pointe sur 1er Sample
  426.         lea.l    Simplet_Samples_Adr(pc),a1    ; Adresse des samples
  427.  
  428.         move.w    Simplet_Samples_Nb(pc),d0
  429.         subq.w    #1,d0
  430.  
  431. Simplet_Next_Sample
  432.         move.l    a3,(a1)+                    ; Note Adresse
  433.  
  434.         move.w    Amiga_Length(a0),d3            ; Longueur Nulle ?
  435.         beq        Simplet_NextSample            ; Alors pas d'instrument
  436.  
  437.         move.w    Amiga_Repeat_Length(a0),d4    ; Longueur de Boucle
  438.         cmp.w    #1,d4                    ; supérieure à 1 ?
  439.         bhi.s    Simplet_Repeat_Length        ; Alors il y a bouclage
  440.  
  441.  
  442. Simplet_No_Repeat_Length
  443.         move.w    d3,d1                ; Longueur
  444.         subq.w    #1,d1
  445. Simplet_Copy_1
  446.         move.w    (a2)+,(a3)+            ; Recopie simplement
  447.         dbra        d1,Simplet_Copy_1        ; le sample
  448.  
  449.         move.w    #1400-1,d2
  450. Simplet_Copy_2
  451.         clr.w    (a3)+                ; et met du vide après
  452.         dbra        d2,Simplet_Copy_2        ; car ne boucle pas
  453.  
  454.         move.w    #1400,d1                ; Repeat Length pour
  455.         bra.s    Simplet_Sample_Ok        ; boucler dans le vide
  456.  
  457.  
  458. Simplet_Repeat_Length
  459.         tst.w    Amiga_Repeat_Start(a0)    ; Y'a t'il un début de boucle?
  460.         bne.s    Simplet_Repeat_Start    ; Oui
  461.  
  462.  
  463.         move.l    a3,a4                ; Note le début du sample
  464.  
  465.         move.w    d3,d1                ; Longueur
  466.         subq.w    #1,d1
  467. Simplet_Copy_3
  468.         move.w    (a2)+,(a3)+            ; Recopie le sample jusqu'à
  469.         dbra        d1,Simplet_Copy_3        ; La fin de la boucle
  470.         bra.s    Simplet_No_Repeat_Start
  471.  
  472.  
  473. Simplet_Repeat_Start
  474.         move.w    Amiga_Repeat_Start(a0),d1    ; On prend le sample
  475.         move.w    d1,d3                    ; jusqu'au début de la
  476.         move.l    a2,a4                    ; boucle
  477.  
  478.         subq.w    #1,d1
  479. Simplet_Copy_4
  480.         move.w    (a4)+,(a3)+
  481.         dbra        d1,Simplet_Copy_4
  482.  
  483.         add.w    Amiga_Length(a0),a2
  484.         add.w    Amiga_Length(a0),a2
  485.  
  486. Simplet_No_Repeat_Start
  487.         move.l    a3,a5
  488.         moveq.l    #0,d1
  489.  
  490. Simplet_Too_Small
  491.         move.l    a4,a6
  492.         move.w    d4,d2
  493.         subq.w    #1,d2
  494.  
  495. Simplet_Copy_5
  496.         move.w    (a6)+,(a3)+
  497.         addq.w    #2,d1
  498.         dbra        d2,Simplet_Copy_5
  499.  
  500.         cmp.w    #1400,d1
  501.         blo.s    Simplet_Too_Small
  502.  
  503.         move.w    #1400/2-1,d2
  504. Simplet_Copy_6
  505.         move.w    (a5)+,(a3)+
  506.         dbra        d2,Simplet_Copy_6
  507.  
  508.  
  509. Simplet_Sample_Ok
  510.         lsl.w    d3
  511.         move.w    d3,Amiga_Length(a0)
  512.         move.w    d1,Amiga_Repeat_Length(a0)
  513.         clr.w    Amiga_Repeat_Start(a0)
  514.  
  515. Simplet_NextSample
  516.         lea.l    Amiga_Size(a0),a0
  517.         dbra        d0,Simplet_Next_Sample
  518.  
  519.  
  520.         move.b    Simplet_Speed(pc),Simplet_Counter
  521.         move.w    #-1,Simplet_Pattern_Position
  522.         clr.w    Simplet_Song_Position
  523.         clr.w    Simplet_Pattern_Break_Position
  524.         sf        Simplet_Pattern_Break_Flag
  525.         sf        Simplet_Position_Jump_Flag
  526.         sf        Simplet_Pattern_Loop_Flag
  527.         clr.b    Simplet_Pattern_Delay_Time
  528.  
  529.  
  530.         lea.l    WorkSpace,a0
  531.         move.l    #1000,d1
  532.         move.l    #500,d2
  533.         move.w    #2345,d4
  534.         moveq.l    #0,d5
  535.  
  536.         lea.l    Simplet_Voices(pc),a6
  537.         moveq.l    #8-1,d7
  538.  
  539. Init_A_Voice
  540.         clr.l    Voice_Sample_Offset(a6)
  541.         clr.l    Voice_Sample_Position(a6)
  542.         move.l    a0,Voice_Sample_Start(a6)
  543.         move.l    d1,Voice_Sample_Length(a6)
  544.         move.l    d2,Voice_Sample_Repeat_Length(a6)
  545.         move.w    d4,Voice_Sample_Period(a6)
  546.         move.w    d5,Voice_Sample_Volume(a6)
  547.         move.l    a0,Voice_Start(a6)
  548.         move.l    d1,Voice_Length(a6)
  549.         move.l    d2,Voice_Repeat_Length(a6)
  550.         move.w    d4,Voice_Period(a6)
  551.         move.w    d5,Voice_Volume(a6)
  552.         move.l    a0,Voice_Funk_Start(a6)
  553.  
  554.         clr.l    Voice_Tone_Port_Direction(a6)
  555.         clr.l    Voice_Vibrato_Position(a6)
  556.         clr.b    Voice_Tremolo_Control(a6)
  557.         clr.w    Voice_Funk_Speed(a6)
  558.         clr.l    Voice_Funk_Position(a6)
  559.  
  560.         lea.l    Voice_Size(a6),a6
  561.         dbra        d7,Init_A_Voice
  562.         rts
  563.  
  564. ***********************************************************************
  565. ***********            Remet les voies à zéro            ***********
  566. ***********************************************************************
  567.  
  568. Clear_Voices
  569.         lea.l    WorkSpace,a0
  570.         move.l    #1000,d1
  571.         move.l    #500,d2
  572.         move.w    #2345,d4
  573.         moveq.l    #0,d5
  574.  
  575.         lea.l    Simplet_Voices(pc),a6
  576.         moveq.l    #8-1,d7
  577.  
  578. Clear_A_Voice
  579.         clr.l    Voice_Sample_Offset(a6)
  580.         clr.l    Voice_Sample_Position(a6)
  581.         move.l    a0,Voice_Sample_Start(a6)
  582.         move.l    d1,Voice_Sample_Length(a6)
  583.         move.l    d2,Voice_Sample_Repeat_Length(a6)
  584.         move.w    d4,Voice_Sample_Period(a6)
  585.         move.w    d5,Voice_Sample_Volume(a6)
  586.         move.l    a0,Voice_Start(a6)
  587.         move.l    d1,Voice_Length(a6)
  588.         move.l    d2,Voice_Repeat_Length(a6)
  589.         move.w    d4,Voice_Period(a6)
  590.         move.w    d5,Voice_Volume(a6)
  591.  
  592.         lea.l    Voice_Size(a6),a6
  593.         dbra        d7,Clear_A_Voice
  594.         rts
  595.  
  596. ***********************************************************************
  597. ***********            Gestion du Soundtrack            ***********
  598. ***********************************************************************
  599.  
  600. Simplet_Play_Patterns
  601.         addq.b    #1,Simplet_Counter
  602.         move.b    Simplet_Counter(pc),d0
  603.         cmp.b    Simplet_Speed(pc),d0
  604.         blo        Simplet_No_New_Note
  605.  
  606.         clr.b    Simplet_Counter
  607.  
  608.         tst.b    Simplet_Pattern_Break_Flag(pc)
  609.         bne.s    Simplet_New_Pattern
  610.  
  611.         tst.b    Simplet_Pattern_Delay_Time(pc)
  612.         beq.s    Simplet_No_Delay
  613.  
  614.         subq.b    #1,Simplet_Pattern_Delay_Time
  615.         bra        Simplet_No_New_Note
  616.  
  617. Simplet_No_Delay
  618.         tst.b    Simplet_Pattern_Loop_Flag(pc)
  619.         beq.s    Simplet_No_Pattern_Loop
  620.  
  621.         move.w    Simplet_Pattern_Loop_Position(pc),Simplet_Pattern_Position
  622.         sf        Simplet_Pattern_Loop_Flag
  623.         bra.s    Simplet_New_Notes
  624.  
  625. Simplet_No_Pattern_Loop
  626.         tst.b    Simplet_Position_Jump_Flag(pc)
  627.         beq.s    Simplet_New_Line
  628.  
  629.         move.w    Simplet_Position_Jump_Pos(pc),d0
  630.         sf        Simplet_Position_Jump_Flag
  631.         bra.s    Simplet_New_Position
  632.  
  633. Simplet_New_Line
  634.         addq.w    #1,Simplet_Pattern_Position
  635.         move.w    Simplet_Pattern_Position(pc),d0
  636.         cmp.w    Simplet_Pattern_Length(pc),d0
  637.         blo.s    Simplet_New_Notes
  638.  
  639. Simplet_New_Pattern
  640.         move.w    Simplet_Song_Position(pc),d0
  641.         addq.w    #1,d0
  642.  
  643. Simplet_New_Position
  644.         move.w    Simplet_Pattern_Break_Position(pc),Simplet_Pattern_Position
  645.         clr.w    Simplet_Pattern_Break_Position
  646.         sf        Simplet_Pattern_Break_Flag
  647.  
  648.         cmp.w    Simplet_Song_Length(pc),d0
  649.         blo.s    Simplet_No_Restart
  650.         move.w    Simplet_Song_Restart(pc),d0
  651.         bne.s    Simplet_No_Restart
  652.  
  653.         move.b    #125,Simplet_Tempo
  654.         move.b    #6,Simplet_Speed
  655.         move.b    #5,Simplet_IT_Timer_Control
  656.         move.b    #192,Simplet_IT_Timer_Data
  657.         move.w    #984,Simplet_IT_Sample_Length
  658.  
  659. Simplet_No_Restart
  660.         move.w    d0,Simplet_Song_Position
  661.  
  662.  
  663. Simplet_New_Notes
  664.         lea.l    Module+20(pc),a5        ; Pointe sur infos samples
  665.         movea.l    Simplet_Sequence_Adr(pc),a0
  666.         move.w    Simplet_Song_Position(pc),d1
  667.         moveq.l    #0,d0
  668.         move.b    (a0,d1.w),d0
  669.         mulu.w    Simplet_Pattern_Size(pc),d0
  670.         movea.l    Simplet_Patterns_Adr(pc),a4
  671.         adda.l    d0,a4                ; Pointe sur le Pattern
  672.         move.w    Simplet_Pattern_Position(pc),d0
  673.         mulu.w    Simplet_Line_Size(pc),d0
  674.         adda.w    d0,a4                ; Pointe sur la Bonne Ligne
  675.  
  676.  
  677.         lea.l    Simplet_Voices(pc),a6
  678.         move.w    Simplet_Voices_Nb(pc),d7
  679.         subq.w    #1,d7
  680. Simplet_New_Notes_Loop
  681.         bsr.s    Simplet_Play_Voice
  682.  
  683.         lea.l    Voice_Size(a6),a6
  684.         dbra        d7,Simplet_New_Notes_Loop
  685.         rts
  686.  
  687.  
  688. Simplet_No_New_Note
  689.         lea.l    Simplet_Voices(pc),a6
  690.         move.w    Simplet_Voices_Nb(pc),d7
  691.         subq.w    #1,d7
  692. Simplet_No_New_Note_Loop
  693.         bsr        Simplet_Check_Efx_2
  694.  
  695.         lea.l    Voice_Size(a6),a6
  696.         dbra        d7,Simplet_No_New_Note_Loop
  697.         rts
  698.  
  699.  
  700. Simplet_Play_Voice
  701.         move.w    (a4)+,d1
  702.         move.b    (a4)+,d2
  703.         move.b    (a4)+,Voice_Parameters(a6)
  704.  
  705.         move.w    d1,d0
  706.         and.w    #$0fff,d0
  707.         move.w    d0,Voice_Note(a6)
  708.         and.w    #$f000,d1
  709.         lsr.w    #8,d1
  710.         move.b    d2,d0
  711.         lsr.b    #4,d0
  712.         add.b    d1,d0
  713.         move.b    d0,Voice_Sample(a6)
  714.         and.b    #$0f,d2
  715.         move.b    d2,Voice_Command(a6)
  716.  
  717.         moveq.l    #0,d2
  718.         move.b    Voice_Sample(a6),d2
  719.         beq.s    Simplet_No_New_Sample
  720.  
  721.         subq.w    #1,d2
  722.         lea.l    Simplet_Samples_Adr(pc),a1
  723.         move.l    (a1,d2.w*4),Voice_Start(a6)
  724.         clr.l    Voice_Sample_Offset(a6)
  725.         mulu.w    #Amiga_Size,d2
  726.         moveq.l    #0,d0
  727.         move.w    Amiga_Length(a5,d2.w),d0
  728.         move.l    d0,Voice_Length(a6)
  729.         move.w    Amiga_Repeat_Length(a5,d2.w),d0
  730.         move.l    d0,Voice_Repeat_Length(a6)
  731.         moveq.l    #0,d0
  732.         move.b    Amiga_Volume(a5,d2.w),d0
  733.         move.w    d0,Voice_Volume(a6)
  734.         move.w    d0,Voice_Sample_Volume(a6)
  735.         move.b    Amiga_Fine_Tune(a5,d2.w),d0
  736.         mulu.w    #12*3*2,d0
  737.         move.w    d0,Voice_Sample_Fine_Tune(a6)
  738.  
  739.         move.w    Amiga_Repeat_Start(a5,d2.w),d0
  740.         add.l    Voice_Start(a6),d0
  741.         move.l    d0,Voice_Funk_Start(a6)
  742.  
  743. Simplet_No_New_Sample
  744.         tst.w    Voice_Note(a6)
  745.         beq        Simplet_Check_Efx_1
  746.  
  747.         move.w    Voice_Command(a6),d0
  748.         and.w    #$0ff0,d0
  749.         cmp.w    #$0e50,d0
  750.         beq.s    Simplet_Do_Set_Fine_Tune
  751.  
  752.         move.b    Voice_Command(a6),d0
  753.         subq.b    #3,d0                ; 3 = Tone Portamento
  754.         beq        Simplet_Set_Tone_Portamento
  755.         subq.b    #2,d0                ; 5 = Tone Porta + Vol Slide
  756.         beq        Simplet_Set_Tone_Portamento
  757.         subq.b    #4,d0                ; 9 = Sample Offset
  758.         bne.s    Simplet_Set_Period
  759.  
  760.         bsr        Simplet_Sample_Offset
  761.         bra.s    Simplet_Set_Period
  762.  
  763. Simplet_Do_Set_Fine_Tune
  764.         bsr        Simplet_Set_Fine_Tune
  765.  
  766. Simplet_Set_Period
  767.         lea.l    Simplet_Period_Table(pc),a0
  768.         move.w    Voice_Note(a6),d0
  769.         bsr        Simplet_Find_Period
  770.         adda.w    Voice_Sample_Fine_Tune(a6),a0
  771.         move.w    (a0),Voice_Period(a6)
  772.  
  773.  
  774.         move.w    Voice_Command(a6),d0
  775.         and.w    #$0ff0,d0
  776.         cmp.w    #$0ed0,d0
  777.         bne.s    Simplet_No_Note_Delay
  778.         move.b    Voice_Parameters(a6),d0
  779.         and.b    #$0f,d0
  780.         beq.s    Simplet_No_Note_Delay
  781.         rts
  782.  
  783. Simplet_No_Note_Delay
  784.         move.w    Voice_Period(a6),Voice_Sample_Period(a6)
  785.         move.l    Voice_Start(a6),Voice_Sample_Start(a6)
  786.         move.l    Voice_Sample_Offset(a6),Voice_Sample_Position(a6)
  787.         move.l    Voice_Length(a6),d0
  788.         move.l    Voice_Repeat_Length(a6),d1
  789.         add.l    d1,d0
  790.         move.l    d0,Voice_Sample_Length(a6)
  791.         move.l    d1,Voice_Sample_Repeat_Length(a6)
  792.  
  793.  
  794.         btst.b    #2,Voice_Vibrato_Control(a6)
  795.         bne.s    Simplet_Vibrato_No_Reset
  796.         clr.b    Voice_Vibrato_Position(a6)
  797. Simplet_Vibrato_No_Reset
  798.  
  799.         btst.b    #2,Voice_Tremolo_Control(a6)
  800.         bne.s    Simplet_Tremolo_No_Reset
  801.         clr.b    Voice_Tremolo_Position(a6)
  802. Simplet_Tremolo_No_Reset
  803.  
  804.  
  805. Simplet_Check_Efx_1
  806.         bsr        Simplet_Funk_Update
  807.         moveq.l    #0,d0
  808.         move.b    Voice_Command(a6),d0
  809.         jmp        ([Jump_Table_1,d0.w*4])
  810.  
  811. Jump_Table_1
  812.         dc.l        Simplet_Period_Nop,Simplet_Period_Nop
  813.         dc.l        Simplet_Period_Nop,Simplet_Period_Nop
  814.         dc.l        Simplet_Period_Nop,Simplet_Period_Nop
  815.         dc.l        Simplet_Period_Nop,Simplet_Period_Nop
  816.         dc.l        Simplet_Period_Nop,Simplet_Period_Nop
  817.         dc.l        Simplet_Period_Nop,Simplet_Position_Jump
  818.         dc.l        Simplet_Volume_Change,Simplet_Pattern_Break
  819.         dc.l        Simplet_E_Commands_1,Simplet_Set_Speed
  820.  
  821. Simplet_E_Commands_1
  822.         move.b    Voice_Parameters(a6),d0
  823.         and.w    #$f0,d0
  824.         lsr.w    #4,d0
  825.         jmp        ([Jump_Table_E1,d0.w*4])
  826.  
  827. Jump_Table_E1
  828.         dc.l        Simplet_Return,Simplet_Fine_Portamento_Up
  829.         dc.l        Simplet_Fine_Portamento_Down,Simplet_Set_Glissando_Control
  830.         dc.l        Simplet_Set_Vibrato_Control,Simplet_Return
  831.         dc.l        Simplet_Pattern_Loop,Simplet_Set_Tremolo_Control
  832.         dc.l        Simplet_Return,Simplet_Retrig_Note
  833.         dc.l        Simplet_Volume_Fine_Up,Simplet_Volume_Slide_Down
  834.         dc.l        Simplet_Note_Cut,Simplet_Return
  835.         dc.l        Simplet_Pattern_Delay,Simplet_Funk_It
  836.  
  837.  
  838. Simplet_Check_Efx_2
  839.         bsr        Simplet_Funk_Update
  840.         moveq.l    #0,d0
  841.         move.b    Voice_Command(a6),d0
  842.         jmp        ([Jump_Table_2,d0.w*4])
  843.  
  844. Jump_Table_2
  845.         dc.l        Simplet_Arpeggio,Simplet_Portamento_Up
  846.         dc.l        Simplet_Portamento_Down,Simplet_Tone_Portamento
  847.         dc.l        Mt_Vibrato,Simplet_Tone_Portamento_Plus_Volume_Slide
  848.         dc.l        Simplet_Vibrato_Plus_Volume_Slide,Mt_Tremolo
  849.         dc.l        Simplet_Return,Simplet_Return
  850.         dc.l        Simplet_Volume_Slide,Simplet_Return
  851.         dc.l        Simplet_Return,Simplet_Return
  852.         dc.l        Simplet_E_Commands_2,Simplet_Return
  853.  
  854. Simplet_E_Commands_2
  855.         move.b    Voice_Parameters(a6),d0
  856.         and.w    #$f0,d0
  857.         lsr.w    #4,d0
  858.         jmp        ([Jump_Table_E2,d0.w*4])
  859.  
  860. Jump_Table_E2
  861.         dc.l        Simplet_Return,Simplet_Return
  862.         dc.l        Simplet_Return,Simplet_Return
  863.         dc.l        Simplet_Return,Simplet_Return
  864.         dc.l        Simplet_Return,Simplet_Return
  865.         dc.l        Simplet_Return,Simplet_Retrig_Note
  866.         dc.l        Simplet_Return,Simplet_Return
  867.         dc.l        Simplet_Note_Cut,Simplet_Note_Delay
  868.         dc.l        Simplet_Return,Simplet_Return
  869.  
  870.  
  871. Simplet_Find_Period
  872.         cmp.w    12*2(a0),d0
  873.         bhs.s    Simplet_Do_Find_Period
  874.         lea.l    12*2(a0),a0
  875.         cmp.w    12*2(a0),d0
  876.         bhs.s    Simplet_Do_Find_Period
  877.         lea.l    12*2(a0),a0
  878.  
  879. Simplet_Do_Find_Period
  880.         moveq.l    #12-1,d3
  881. Simplet_Find_Period_Loop
  882.         cmp.w    (a0)+,d0
  883.         dbhs        d3,Simplet_Find_Period_Loop
  884.         blo.s    Simplet_Period_Found
  885.         subq.l    #2,a0
  886. Simplet_Period_Found
  887.         rts
  888.  
  889.  
  890. Simplet_Period_Nop
  891.         move.w    Voice_Period(a6),Voice_Sample_Period(a6)
  892.  
  893. Simplet_Return
  894.         rts
  895.  
  896. Simplet_Arpeggio_Table
  897.         dc.b        0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0
  898.         dc.b        1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1
  899.  
  900. Simplet_Arpeggio
  901.         move.b    Voice_Parameters(a6),d1
  902.         beq.s    Simplet_Period_Nop
  903.  
  904.         moveq.l    #0,d0
  905.         move.b    Simplet_Counter(pc),d0
  906.         move.b    Simplet_Arpeggio_Table(pc,d0.w),d0
  907.         beq.s    Simplet_Period_Nop
  908.         subq.b    #2,d0
  909.         beq.s    Simplet_Arpeggio_2
  910.  
  911. Simplet_Arpeggio_1
  912.         lsr.w    #4,d1
  913. Simplet_Arpeggio_2
  914.         and.w    #$f,d1
  915.  
  916.         lea.l    Simplet_Period_Table(pc),a0
  917.         adda.w    Voice_Sample_Fine_Tune(a6),a0
  918.         move.w    Voice_Period(a6),d0
  919.         bsr.s    Simplet_Find_Period
  920.         move.w    (a0,d1.w*2),Voice_Sample_Period(a6)
  921.         rts
  922.  
  923.  
  924. Simplet_Portamento_Up
  925.         moveq.l    #0,d0
  926.         move.b    Voice_Parameters(a6),d0
  927.  
  928. Simplet_Portamento_Up2
  929.         sub.w    d0,Voice_Period(a6)
  930.         move.w    Voice_Period(a6),d0
  931.         cmp.w    #113,d0
  932.         bhi.s    Simplet_Portamento_Up_Ok
  933.         move.w    #113,Voice_Period(a6)
  934.  
  935. Simplet_Portamento_Up_Ok
  936.         move.w    Voice_Period(a6),Voice_Sample_Period(a6)
  937.         rts
  938.  
  939.  
  940. Simplet_Portamento_Down
  941.         moveq.l    #0,d0
  942.         move.b    Voice_Parameters(a6),d0
  943. Simplet_Portamento_Down2
  944.         add.w    d0,Voice_Period(a6)
  945.         move.w    Voice_Period(a6),d0
  946.         cmp.w    #856,d0
  947.         blo.s    Simplet_Portamento_Down_Ok
  948.         move.w    #856,Voice_Period(a6)
  949.  
  950. Simplet_Portamento_Down_Ok
  951.         move.w    Voice_Period(a6),Voice_Sample_Period(a6)
  952.         rts
  953.  
  954.  
  955. Simplet_Set_Tone_Portamento
  956.         lea.l    Simplet_Period_Table(pc),a0
  957.         move.w    Voice_Note(a6),d0
  958.         bsr        Simplet_Find_Period
  959.         adda.w    Voice_Sample_Fine_Tune(a6),a0
  960.         move.w    (a0),d0
  961.  
  962.         move.w    d0,Voice_Wanted_Period(a6)
  963.         move.w    Voice_Period(a6),d1
  964.         sf        Voice_Tone_Port_Direction(a6)
  965.         cmp.w    d1,d0
  966.         beq.s    Simplet_Clear_Tone_Portamento
  967.         bge        Simplet_Period_Nop
  968.         st        Voice_Tone_Port_Direction(a6)
  969.         rts
  970.  
  971. Simplet_Clear_Tone_Portamento
  972.         clr.w    Voice_Wanted_Period(a6)
  973.         rts
  974.  
  975. Simplet_Tone_Portamento
  976.         move.b    Voice_Parameters(a6),d0
  977.         beq.s    Simplet_Tone_Portamento_No_Change
  978.         move.b    d0,Voice_Tone_Port_Speed(a6)
  979.         clr.b    Voice_Parameters(a6)
  980.  
  981. Simplet_Tone_Portamento_No_Change
  982.         tst.w    Voice_Wanted_Period(a6)
  983.         beq        Simplet_Period_Nop
  984.         moveq.l    #0,d0
  985.         move.b    Voice_Tone_Port_Speed(a6),d0
  986.         tst.b    Voice_Tone_Port_Direction(a6)
  987.         bne.s    Simplet_Tone_Portamento_Up
  988.  
  989. Simplet_Tone_Portamento_Down
  990.         add.w    d0,Voice_Period(a6)
  991.         move.w    Voice_Wanted_Period(a6),d0
  992.         cmp.w    Voice_Period(a6),d0
  993.         bgt.s    Simplet_Tone_Portamento_Set_Period
  994.         move.w    Voice_Wanted_Period(a6),Voice_Period(a6)
  995.         clr.w    Voice_Wanted_Period(a6)
  996.         bra.s    Simplet_Tone_Portamento_Set_Period
  997.  
  998. Simplet_Tone_Portamento_Up
  999.         sub.w    d0,Voice_Period(a6)
  1000.         move.w    Voice_Wanted_Period(a6),d0
  1001.         cmp.w    Voice_Period(a6),d0
  1002.         blt.s    Simplet_Tone_Portamento_Set_Period
  1003.         move.w    Voice_Wanted_Period(a6),Voice_Period(a6)
  1004.         clr.w    Voice_Wanted_Period(a6)
  1005.  
  1006.  
  1007. Simplet_Tone_Portamento_Set_Period
  1008.         move.w    Voice_Period(a6),d0
  1009.         tst.b    Voice_Glissando_Control(a6)
  1010.         beq.s    Simplet_Glissando_Skip
  1011.  
  1012.         lea.l    Simplet_Period_Table(pc),a0
  1013.         adda.w    Voice_Sample_Fine_Tune(a6),a0
  1014.         bsr        Simplet_Find_Period
  1015.         move.w    (a0),d0
  1016.  
  1017. Simplet_Glissando_Skip
  1018.         move.w    d0,Voice_Sample_Period(a6)
  1019.         rts
  1020.  
  1021.  
  1022. Mt_Vibrato
  1023.         move.b    Voice_Parameters(a6),d0
  1024.         beq.s    Mt_Vibrato2
  1025.         move.b    Voice_Vibrato_Command(a6),d2
  1026.         and.b    #$0f,d0
  1027.         beq.s    Mt_VibSkip
  1028.         and.b    #$f0,d2
  1029.         or.b        d0,d2
  1030. Mt_VibSkip
  1031.         move.b    Voice_Parameters(a6),d0
  1032.         and.b    #$f0,d0
  1033.         beq.s    Mt_vibskip2
  1034.         and.b    #$0f,d2
  1035.         or.b        d0,d2
  1036. Mt_vibskip2
  1037.         move.b    d2,Voice_Vibrato_Command(a6)
  1038. Mt_Vibrato2
  1039.         move.b    Voice_Vibrato_Position(a6),d0
  1040.         lea.l    Simplet_Sinus_Table(pc),a3
  1041.         lsr.w    #2,d0
  1042.         and.w    #$001f,d0
  1043.         moveq.l    #0,d2
  1044.         move.b    Voice_Vibrato_Control(a6),d2
  1045.         and.b    #$3,d2
  1046.         beq.s    Mt_Vib_Sine
  1047.         lsl.b    #3,d0
  1048.         cmp.b    #1,d2
  1049.         beq.s    Mt_Vib_RampDown
  1050.         move.b    #255,d2
  1051.         bra.s    Mt_Vib_Set
  1052. Mt_Vib_RampDown
  1053.         tst.b    Voice_Vibrato_Position(a6)
  1054.         bpl.s    Mt_Vib_RampDown2
  1055.         move.b    #255,d2
  1056.         sub.b    d0,d2
  1057.         bra.s    Mt_Vib_Set
  1058. Mt_Vib_RampDown2
  1059.         move.b    d0,d2
  1060.         bra.s    Mt_Vib_Set
  1061. Mt_Vib_Sine
  1062.         move.b    (a3,d0.w),d2
  1063. Mt_Vib_Set
  1064.         move.b    Voice_Vibrato_Command(a6),d0
  1065.         and.w    #15,d0
  1066.         mulu.w    d0,d2
  1067.         lsr.w    #7,d2
  1068.         move.w    Voice_Period(a6),d0
  1069.         tst.b    Voice_Vibrato_Position(a6)
  1070.         bmi.s    Mt_VibratoNeg
  1071.         add.w    d2,d0
  1072.         bra.s    Mt_Vibrato3
  1073. Mt_VibratoNeg
  1074.         sub.w    d2,d0
  1075. Mt_Vibrato3
  1076.         move.w    d0,Voice_Sample_Period(a6)
  1077.         move.b    Voice_Vibrato_Command(a6),d0
  1078.         lsr.w    #2,d0
  1079.         and.w    #$003c,d0
  1080.         add.b    d0,Voice_Vibrato_Position(a6)
  1081.         rts
  1082.  
  1083. Simplet_Tone_Portamento_Plus_Volume_Slide
  1084.         bsr        Simplet_Tone_Portamento_No_Change
  1085.         bra        Simplet_Volume_Slide
  1086.  
  1087.  
  1088. Simplet_Vibrato_Plus_Volume_Slide
  1089.         bsr.s    Mt_Vibrato2
  1090.         bra        Simplet_Volume_Slide
  1091.  
  1092. Mt_Tremolo
  1093.         move.b    Voice_Parameters(a6),d0
  1094.         beq.s    Mt_Tremolo2
  1095.         move.b    Voice_Tremolo_Command(a6),d2
  1096.         and.b    #$0f,d0
  1097.         beq.s    Mt_treskip
  1098.         and.b    #$f0,d2
  1099.         or.b        d0,d2
  1100. Mt_treskip
  1101.         move.b    Voice_Parameters(a6),d0
  1102.         and.b    #$f0,d0
  1103.         beq.s    Mt_treskip2
  1104.         and.b    #$0f,d2
  1105.         or.b        d0,d2
  1106. Mt_treskip2
  1107.         move.b    d2,Voice_Tremolo_Command(a6)
  1108. Mt_Tremolo2
  1109.         move.b    Voice_Tremolo_Position(a6),d0
  1110.         lea.l    Simplet_Sinus_Table(pc),a3
  1111.         lsr.w    #2,d0
  1112.         and.w    #$001f,d0
  1113.         moveq.l    #0,d2
  1114.         move.b    Voice_Tremolo_Control(a6),d2
  1115.         and.b    #$3,d2
  1116.         beq.s    Mt_tre_sine
  1117.         lsl.b    #3,d0
  1118.         cmp.b    #1,d2
  1119.         beq.s    Mt_tre_rampdown
  1120.         move.b    #255,d2
  1121.         bra.s    Mt_tre_set
  1122. Mt_tre_rampdown
  1123.         tst.b    Voice_Tremolo_Position(a6)
  1124.         bpl.s    Mt_tre_rampdown2
  1125.         move.b    #255,d2
  1126.         sub.b    d0,d2
  1127.         bra.s    Mt_tre_set
  1128. Mt_tre_rampdown2
  1129.         move.b    d0,d2
  1130.         bra.s    Mt_tre_set
  1131. Mt_tre_sine
  1132.         move.b    (a3,d0.w),d2
  1133. Mt_tre_set
  1134.         move.b    Voice_Tremolo_Command(a6),d0
  1135.         and.w    #15,d0
  1136.         mulu.w    d0,d2
  1137.         lsr.w    #6,d2
  1138.         moveq.l    #0,d0
  1139.         move.w    Voice_Volume(a6),d0
  1140.         tst.b    Voice_Tremolo_Position(a6)
  1141.         bmi.s    Mt_TremoloNeg
  1142.         add.w    d2,d0
  1143.         bra.s    Mt_Tremolo3
  1144. Mt_TremoloNeg
  1145.         sub.w    d2,d0
  1146. Mt_Tremolo3
  1147.         bpl.s    Mt_TremoloSkip
  1148.         clr.w    d0
  1149. Mt_TremoloSkip
  1150.         cmp.w    #$40,d0
  1151.         bls.s    Mt_TremoloOk
  1152.         move.w    #$40,d0
  1153. Mt_TremoloOk
  1154.         move.w    d0,Voice_Sample_Volume(a6)
  1155.         move.b    Voice_Tremolo_Command(a6),d0
  1156.         lsr.w    #2,d0
  1157.         and.w    #$003c,d0
  1158.         add.b    d0,Voice_Tremolo_Position(a6)
  1159.         bra        Simplet_Period_Nop
  1160.  
  1161.  
  1162. Simplet_Sample_Offset
  1163.         move.l    Voice_Sample_Offset(a6),d1
  1164.         moveq.l    #0,d0
  1165.         move.b    Voice_Parameters(a6),d0
  1166.         beq.s    Simplet_Sample_Offset_No_New
  1167.  
  1168.         lsl.w    #8,d0
  1169.         move.l    d0,d1
  1170. Simplet_Sample_Offset_No_New
  1171.  
  1172.         move.l    Voice_Sample_Offset(a6),d0
  1173.         add.l    d1,d0
  1174.         cmp.l    Voice_Length(a6),d0
  1175.         ble.s    Simplet_Sample_Offset_Ok
  1176.         move.l    Voice_Length(a6),d0
  1177. Simplet_Sample_Offset_Ok
  1178.         move.l    d0,Voice_Sample_Offset(a6)
  1179.         move.l    d0,Voice_Sample_Position(a6)
  1180.         rts
  1181.  
  1182.  
  1183. Simplet_Volume_Slide
  1184.         moveq.l    #0,d0
  1185.         move.b    Voice_Parameters(a6),d0
  1186.         lsr.w    #4,d0
  1187.         beq.s    Simplet_Volume_Slide_Down
  1188.  
  1189. Simplet_Volume_Slide_Up
  1190.         add.w    d0,Voice_Volume(a6)
  1191.         cmp.w    #$40,Voice_Volume(a6)
  1192.         ble.s    Simplet_Volume_Slide_Up_Ok
  1193.         move.w    #$40,Voice_Volume(a6)
  1194.  
  1195. Simplet_Volume_Slide_Up_Ok
  1196.         move.w    Voice_Volume(a6),Voice_Sample_Volume(a6)
  1197.         bra        Simplet_Period_Nop
  1198.  
  1199.  
  1200. Simplet_Volume_Slide_Down
  1201.         move.b    Voice_Parameters(a6),d0
  1202.         and.w    #$0f,d0
  1203.  
  1204. Simplet_Volume_Slide_Down2
  1205.         sub.w    d0,Voice_Volume(a6)
  1206.         bpl.s    Simplet_Volume_Slide_Down_Ok
  1207.         clr.w    Voice_Volume(a6)
  1208.  
  1209. Simplet_Volume_Slide_Down_Ok
  1210.         move.w    Voice_Volume(a6),Voice_Sample_Volume(a6)
  1211.         bra        Simplet_Period_Nop
  1212.  
  1213.  
  1214. Simplet_Position_Jump
  1215.         moveq.l    #0,d0
  1216.         move.b    Voice_Parameters(a6),d0
  1217.  
  1218.         move.w    d0,Simplet_Position_Jump_Pos
  1219.         st        Simplet_Position_Jump_Flag
  1220.         rts
  1221.  
  1222.  
  1223. Simplet_Volume_Change
  1224.         moveq.l    #0,d0
  1225.         move.b    Voice_Parameters(a6),d0
  1226.         cmp.b    #$40,d0
  1227.         ble.s    Simplet_Volume_Change_Ok
  1228.         moveq.l    #$40,d0
  1229.  
  1230. Simplet_Volume_Change_Ok
  1231.         move.w    d0,Voice_Volume(a6)
  1232.         move.w    d0,Voice_Sample_Volume(a6)
  1233.         rts
  1234.  
  1235.  
  1236. Simplet_Pattern_Break
  1237.         moveq.l    #0,d0
  1238.  
  1239.         tst.b    Simplet_Old_Module(pc)
  1240.         bne.s    Simplet_Pattern_Break_Ok
  1241.  
  1242.         move.b    Voice_Parameters(a6),d0
  1243.  
  1244.         move.w    d0,d2            ; Codage en BCD
  1245.         lsr.w    #4,d0            ; premier chiffre
  1246.         mulu.w    #10,d0            ; les dizaines
  1247.         and.w    #$0f,d2            ; deuxième chiffre
  1248.         add.w    d2,d0            ; les unités
  1249.  
  1250.         cmp.w    Simplet_Pattern_Length(pc),d0
  1251.         blo.s    Simplet_Pattern_Break_Ok
  1252.         moveq.l    #0,d0
  1253.     
  1254. Simplet_Pattern_Break_Ok
  1255.         move.w    d0,Simplet_Pattern_Break_Position
  1256.         st        Simplet_Pattern_Break_Flag
  1257.         rts
  1258.  
  1259.  
  1260. Simplet_Set_Speed
  1261.         moveq.l    #0,d0
  1262.         move.b    Voice_Parameters(a6),d0
  1263.         beq.s    Simplet_End
  1264.         cmp.b    #32,d0
  1265.         bhi.s    Simplet_Set_Tempo
  1266.         move.b    d0,Simplet_Speed
  1267. Simplet_End
  1268.         rts
  1269.  
  1270. Simplet_Set_Tempo
  1271.         move.b    d0,Simplet_Tempo
  1272.         sub.b    #32,d0
  1273.         lea.l    Simplet_Tempo_Table(pc),a2
  1274.         move.w    (a2,d0.w*4),Simplet_IT_Sample_Length
  1275.         move.b    2(a2,d0.w*4),Simplet_IT_Timer_Control
  1276.         move.b    3(a2,d0.w*4),Simplet_IT_Timer_Data
  1277.         rts
  1278.  
  1279.  
  1280. Simplet_Fine_Portamento_Up
  1281.         move.b    Voice_Parameters(a6),d0
  1282.         and.w    #$0f,d0
  1283.         bra        Simplet_Portamento_Up2
  1284.  
  1285. Simplet_Fine_Portamento_Down
  1286.         move.b    Voice_Parameters(a6),d0
  1287.         and.w    #$0f,d0
  1288.         bra        Simplet_Portamento_Down2
  1289.  
  1290.  
  1291. Simplet_Set_Glissando_Control
  1292.         move.b    Voice_Parameters(a6),Voice_Glissando_Control(a6)
  1293.         rts
  1294.  
  1295. Simplet_Set_Vibrato_Control
  1296.         move.b    Voice_Parameters(a6),Voice_Vibrato_Control(a6)
  1297.         rts
  1298.  
  1299. Simplet_Set_Fine_Tune
  1300.         move.b    Voice_Parameters(a6),d0
  1301.         and.w    #$0f,d0
  1302.         mulu.w    #12*3*2,d0
  1303.         move.w    d0,Voice_Sample_Fine_Tune(a6)
  1304.         rts
  1305.  
  1306. Simplet_Pattern_Loop
  1307.         move.b    Voice_Parameters(a6),d0
  1308.         and.w    #$0f,d0
  1309.         beq.s    Simplet_Set_Loop_Position
  1310.  
  1311.         tst.w    Simplet_Pattern_Loop_Counter(pc)
  1312.         beq.s    Simplet_Set_Loop_Counter
  1313.  
  1314.         subq.w    #1,Simplet_Pattern_Loop_Counter
  1315.         beq        Simplet_Return
  1316.  
  1317. Simplet_Do_Loop    
  1318.         st        Simplet_Pattern_Loop_Flag
  1319.         rts
  1320. Simplet_Set_Loop_Counter
  1321.         move.w    d0,Simplet_Pattern_Loop_Counter
  1322.         bra.s    Simplet_Do_Loop
  1323. Simplet_Set_Loop_Position
  1324.         move.w    Simplet_Pattern_Position(pc),Simplet_Pattern_Loop_Position
  1325.         rts
  1326.  
  1327.  
  1328. Simplet_Set_Tremolo_Control
  1329.         move.b    Voice_Parameters(a6),Voice_Tremolo_Control(a6)
  1330.         rts
  1331.  
  1332.  
  1333. Simplet_Retrig_Note
  1334.         move.b    Voice_Parameters(a6),d0
  1335.         and.w    #$0f,d0
  1336.         beq.s    Simplet_No_Retrig_Note
  1337.  
  1338.         moveq.l    #0,d1
  1339.         move.b    Simplet_Counter(pc),d1
  1340.         bne.s    Simplet_Retrig_Note_Skip
  1341.  
  1342.         tst.w    Voice_Note(a6)
  1343.         bne.s    Simplet_No_Retrig_Note
  1344.  
  1345. Simplet_Retrig_Note_Skip
  1346.         divu.w    d0,d1
  1347.         swap.w    d1
  1348.         tst.w    d1
  1349.         bne.s    Simplet_No_Retrig_Note
  1350.  
  1351.         move.w    Voice_Period(a6),Voice_Sample_Period(a6)
  1352.         move.l    Voice_Sample_Offset(a6),Voice_Sample_Position(a6)
  1353.  
  1354. Simplet_No_Retrig_Note
  1355.         rts
  1356.  
  1357.  
  1358. Simplet_Volume_Fine_Up
  1359.         move.b    Voice_Parameters(a6),d0
  1360.         and.w    #$0f,d0
  1361.         bra        Simplet_Volume_Slide_Up
  1362.  
  1363.  
  1364. Simplet_Note_Cut
  1365.         move.b    Voice_Parameters(a6),d0
  1366.         and.b    #$0f,d0
  1367.         cmp.b    Simplet_Counter(pc),d0
  1368.         bne        Simplet_Return
  1369.         clr.w    Voice_Volume(a6)
  1370.         clr.w    Voice_Sample_Volume(a6)
  1371.         rts
  1372.  
  1373. Simplet_Note_Delay
  1374.         move.b    Voice_Parameters(a6),d0
  1375.         and.b    #$0f,d0
  1376.         cmp.b    Simplet_Counter(pc),d0
  1377.         bne        Simplet_Return
  1378.         tst.w    Voice_Note(a6)
  1379.         beq        Simplet_Return
  1380.  
  1381.         move.w    Voice_Period(a6),Voice_Sample_Period(a6)
  1382.         move.l    Voice_Start(a6),Voice_Sample_Start(a6)
  1383.         move.l    Voice_Sample_Offset(a6),Voice_Sample_Position(a6)
  1384.         move.l    Voice_Length(a6),d0
  1385.         move.l    Voice_Repeat_Length(a6),d1
  1386.         add.l    d1,d0
  1387.         move.l    d0,Voice_Sample_Length(a6)
  1388.         move.l    d1,Voice_Sample_Repeat_Length(a6)
  1389.         rts
  1390.  
  1391.  
  1392. Simplet_Pattern_Delay
  1393.         tst.b    Simplet_Pattern_Delay_Time(pc)
  1394.         bne        Simplet_Return
  1395.         move.b    Voice_Parameters(a6),d0
  1396.         and.b    #$0f,d0
  1397.         move.b    d0,Simplet_Pattern_Delay_Time
  1398.         rts
  1399.  
  1400.  
  1401. Simplet_Funk_It
  1402.         move.b    Voice_Parameters(a6),d0
  1403.         and.b    #$0f,d0
  1404.         move.b    d0,Voice_Funk_Speed(a6)
  1405.         beq        Simplet_Return
  1406.  
  1407. Simplet_Funk_Update
  1408.         moveq.l    #0,d0
  1409.         move.b    Voice_Funk_Speed(a6),d0
  1410.         beq        Simplet_Return
  1411.  
  1412.         lea.l    Simplet_Funk_Table(pc),a0
  1413.         move.b    (a0,d0.w),d0
  1414.         add.b    d0,Voice_Funk_Offset(a6)
  1415.         btst.b    #7,Voice_Funk_Offset(a6)
  1416.         beq        Simplet_Return
  1417.  
  1418.         clr.b    Voice_Funk_Offset(a6)
  1419.  
  1420.         movea.l    Voice_Funk_Position(a6),a0
  1421.         addq.w    #1,a0
  1422.         cmpa.l    Voice_Repeat_Length(a6),a0
  1423.         blo.s    Simplet_Funk_Ok
  1424.         movea.w    #0,a0
  1425. Simplet_Funk_Ok
  1426.         move.l    a0,Voice_Funk_Position(a6)
  1427.         add.l    Voice_Funk_Start(a6),a0
  1428.         moveq.l    #-1,d0
  1429.         sub.b    (a0),d0
  1430.         move.b    d0,(a0)
  1431.         rts        
  1432.  
  1433.  
  1434. Simplet_Sinus_Table    
  1435.         dc.b        0,24,49,74,97,120,141,161,180,197,212,224
  1436.         dc.b        235,244,250,253,255,253,250,244,235,224
  1437.         dc.b        212,197,180,161,141,120,97,74,49,24
  1438.  
  1439. Simplet_Funk_Table
  1440.         dc.b        0,5,6,7,8,10,11,13,16,19,22,26,32,43,64,128
  1441.  
  1442.  
  1443. Simplet_Period_Table
  1444. ; Tuning 0, Normal
  1445.         dc.w 856,808,762,720,678,640,604,570,538,508,480,453
  1446.         dc.w 428,404,381,360,339,320,302,285,269,254,240,226
  1447.         dc.w 214,202,190,180,170,160,151,143,135,127,120,113
  1448. ; Tuning 1
  1449.         dc.w 850,802,757,715,674,637,601,567,535,505,477,450
  1450.         dc.w 425,401,379,357,337,318,300,284,268,253,239,225
  1451.         dc.w 213,201,189,179,169,159,150,142,134,126,119,113
  1452. ; Tuning 2
  1453.         dc.w 844,796,752,709,670,632,597,563,532,502,474,447
  1454.         dc.w 422,398,376,355,335,316,298,282,266,251,237,224
  1455.         dc.w 211,199,188,177,167,158,149,141,133,125,118,112
  1456. ; Tuning 3
  1457.         dc.w 838,791,746,704,665,628,592,559,528,498,470,444
  1458.         dc.w 419,395,373,352,332,314,296,280,264,249,235,222
  1459.         dc.w 209,198,187,176,166,157,148,140,132,125,118,111
  1460. ; Tuning 4
  1461.         dc.w 832,785,741,699,660,623,588,555,524,495,467,441
  1462.         dc.w 416,392,370,350,330,312,294,278,262,247,233,220
  1463.         dc.w 208,196,185,175,165,156,147,139,131,124,117,110
  1464. ; Tuning 5
  1465.         dc.w 826,779,736,694,655,619,584,551,520,491,463,437
  1466.         dc.w 413,390,368,347,328,309,292,276,260,245,232,219
  1467.         dc.w 206,195,184,174,164,155,146,138,130,123,116,109
  1468. ; Tuning 6
  1469.         dc.w 820,774,730,689,651,614,580,547,516,487,460,434
  1470.         dc.w 410,387,365,345,325,307,290,274,258,244,230,217
  1471.         dc.w 205,193,183,172,163,154,145,137,129,122,115,109
  1472. ; Tuning 7
  1473.         dc.w 814,768,725,684,646,610,575,543,513,484,457,431
  1474.         dc.w 407,384,363,342,323,305,288,272,256,242,228,216
  1475.         dc.w 204,192,181,171,161,152,144,136,128,121,114,108
  1476. ; Tuning -8
  1477.         dc.w 907,856,808,762,720,678,640,604,570,538,508,480
  1478.         dc.w 453,428,404,381,360,339,320,302,285,269,254,240
  1479.         dc.w 226,214,202,190,180,170,160,151,143,135,127,120
  1480. ; Tuning -7
  1481.         dc.w 900,850,802,757,715,675,636,601,567,535,505,477
  1482.         dc.w 450,425,401,379,357,337,318,300,284,268,253,238
  1483.         dc.w 225,212,200,189,179,169,159,150,142,134,126,119
  1484. ; Tuning -6
  1485.         dc.w 894,844,796,752,709,670,632,597,563,532,502,474
  1486.         dc.w 447,422,398,376,355,335,316,298,282,266,251,237
  1487.         dc.w 223,211,199,188,177,167,158,149,141,133,125,118
  1488. ; Tuning -5
  1489.         dc.w 887,838,791,746,704,665,628,592,559,528,498,470
  1490.         dc.w 444,419,395,373,352,332,314,296,280,264,249,235
  1491.         dc.w 222,209,198,187,176,166,157,148,140,132,125,118
  1492. ; Tuning -4
  1493.         dc.w 881,832,785,741,699,660,623,588,555,524,494,467
  1494.         dc.w 441,416,392,370,350,330,312,294,278,262,247,233
  1495.         dc.w 220,208,196,185,175,165,156,147,139,131,123,117
  1496. ; Tuning -3
  1497.         dc.w 875,826,779,736,694,655,619,584,551,520,491,463
  1498.         dc.w 437,413,390,368,347,328,309,292,276,260,245,232
  1499.         dc.w 219,206,195,184,174,164,155,146,138,130,123,116
  1500. ; Tuning -2
  1501.         dc.w 868,820,774,730,689,651,614,580,547,516,487,460
  1502.         dc.w 434,410,387,365,345,325,307,290,274,258,244,230
  1503.         dc.w 217,205,193,183,172,163,154,145,137,129,122,115
  1504. ; Tuning -1
  1505.         dc.w 862,814,768,725,684,646,610,575,543,513,484,457
  1506.         dc.w 431,407,384,363,342,323,305,288,272,256,242,228
  1507.         dc.w 216,203,192,181,171,161,152,144,136,128,121,114
  1508.  
  1509.  
  1510. ; Table qui contient les paramètres pour l'interruption Timer
  1511. ; et le nombre de samples à calculer en fonction du Tempo
  1512.  
  1513. Simplet_Tempo_Table            IncBin    'TEMPODSP.TAB'
  1514.  
  1515. ; Variables de gestion
  1516.  
  1517.                             ds.b        1
  1518. Simplet_Old_Module                ds.b        1
  1519. Simplet_Sequence_Adr            ds.l        1
  1520. Simplet_Patterns_Adr            ds.l        1
  1521. Simplet_Line_Size                ds.w        1
  1522. Simplet_Pattern_Size            ds.w        1
  1523. Simplet_Samples_Adr                ds.l        31
  1524.  
  1525. Simplet_Voices_Nb                ds.w        1
  1526. Simplet_Samples_Nb                ds.w        1
  1527.  
  1528. Simplet_Song_Position            ds.w        1
  1529. Simplet_Song_Length                ds.w        1
  1530. Simplet_Song_Restart            ds.w        1
  1531.  
  1532. Simplet_Pattern_Position            ds.w        1
  1533. Simplet_Pattern_Length            ds.w        1
  1534.  
  1535. Simplet_Pattern_Loop_Counter        ds.w        1
  1536. Simplet_Pattern_Loop_Position        ds.w        1
  1537. Simplet_Pattern_Break_Position    ds.w        1
  1538. Simplet_Position_Jump_Pos        ds.w        1
  1539. Simplet_Pattern_Loop_Flag        ds.b        1
  1540. Simplet_Pattern_Break_Flag        ds.b        1
  1541. Simplet_Position_Jump_Flag        ds.b        1
  1542. Simplet_Pattern_Delay_Time        ds.b        1
  1543. Simplet_Tempo                    ds.b        1
  1544. Simplet_Speed                    ds.b        1
  1545. Simplet_Counter                ds.b        1
  1546.  
  1547. Simplet_IT_In_Service            ds.b        1
  1548. Simplet_IT_Timer_Control            ds.b        1
  1549. Simplet_IT_Timer_Data            ds.b        1
  1550. Simplet_IT_Sample_Length            ds.w        1
  1551.  
  1552. Simplet_Voices                    ds.b        8*Voice_Size
  1553.  
  1554. ; Pour un enchainement stéréo Amiga  L R R L L R R L
  1555. Increment_Voice_1            dc.w        2*Voice_Size
  1556. Increment_Voice_2            dc.w        -Voice_Size
  1557. Increment_Voice_3            dc.w        2*Voice_Size
  1558. Increment_Voice_4            dc.w        Voice_Size
  1559.  
  1560. ; Pour un enchainement stéréo simple L R L R L R L R
  1561. *Increment_Voice_1            dc.w        Voice_Size
  1562. *Increment_Voice_2            dc.w        Voice_Size
  1563. *Increment_Voice_3            dc.w        Voice_Size
  1564. *Increment_Voice_4            dc.w        Voice_Size
  1565.  
  1566. ***********************************************************************
  1567. ***********                Routine DSP                ***********
  1568. ***********************************************************************
  1569.  
  1570. DSP_Code        IncBin    'TRACKER.P56'
  1571. DSP_End        Even
  1572.  
  1573. ***********************************************************************
  1574. ***********                Section BSS                ***********
  1575. ***********************************************************************
  1576.  
  1577.             Section    BSS
  1578.  
  1579.             ds.l        150*1024/4        ; WorkSpace
  1580. WorkSpace        ds.l        1000/4            ; premier de la section BSS
  1581.